#include <iostream>
using namespace std;

int main()
{
  int board[3] [3];

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      board[i] [j] = rand() % 2;
      cout << board[i] [j] << " ";
    }

    cout << endl;
  }

  // Check rows
  for (int i = 0; i < 3; i++)
    if (board[i] [0] == board[i] [1] && board[i] [0] == board[i] [2])
      cout << "All " << board[i] [0] << "'s on row " << i << endl;

  // Check columns
  for (int j = 0; j < 3; j++)
    if (board[0] [j] == board[1] [j] && board[0] [j] == board[2] [j])
      cout << "All " << board[0] [j] << "'s on column " << j << endl;


  // Check major diagonal
  if (board[0] [0] == board[1] [1] && board[0] [0] == board[2] [2])
    cout << "All " << board[0] [0] << "'s on major diagonal" << endl;

  // Check subdiagonal
  if (board[0] [2] == board[1] [1] && board[0] [2] == board[2] [0])
    cout << "All " << board[0] [2] << "'s on subdiagonal" << endl;

  return 0;
}
